<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <title>重置密码</title>
    <link rel="stylesheet" href="css/main.css" />
    <link rel="stylesheet" href="css/resetpass.css" />
    <link rel="stylesheet" href="iconfont/iconfont.css" />
    <link rel="stylesheet" href="//at.alicdn.com/t/font_513019_1cv052p8rccy2e29.css" />
    <link rel="stylesheet" href="//at.alicdn.com/t/font_513825_ejbywdxlh74lsor.css" />
</head>
<body>
    <!--header开始-->
      <header>
      	<div class="iconfont icon-fanhui mui-action-back" style="font-size:0.34rem"></div>
      	<div style="font-size:0.34rem;color:#fff;">重置密码</div>
      </header>
    <!--header结束-->
    <!--表单的开始-->
    <form action="" class="form">
   
    	<!--密码-->
        <div  class="username">
    		<div>
    		<img src="img/icon_code@2x.png" alt=""  style="width:0.32rem;height:0.40rem;margin-right:0.35rem;"/>
    		<input type="password" name="userpass" placeholder="请输入密码" />
    		</div>
    	</div>
    	<!--确认密码-->
        <div  class="username">
    		<div>
    		<img src="img/icon_code@2x.png" alt=""  style="width:0.32rem;height:0.40rem;margin-right:0.35rem;"/>
    		<input type="password" name="userpassAgain" placeholder="确认密码" />
    		</div>
    	</div>
    	<!--创建帐号-->
    	<div class="next">确定</div>
    </form>
    <!--表单的结束-->

</body>
<script type="text/javascript" src="js/pxtorem.js"></script>
<script src="js/apptool.js"></script>
<script src="js/mui.js"></script>
<script>
	mui.init();
	mui.plusReady(function(){
		//执行返回键
		webtool.newback();
		//重置密码
		mui('.next')[0].addEventListener('tap',function(e){
			var userpassValue=mui('input[name=userpass]')[0].value;
			var userpassAgainValue=mui('input[name=userpassAgain]')[0].value;
			if(!userpassValue){
				mui.toast('新密码不能为空');
				return;
			}else{
				if(!userpassAgainValue){
					mui.toast('确认密码不能为空');
				    return;
				}else{
					if(!apptools.checkpass(userpassValue)){
				        return;
					}else{
						if(!apptools.checkpass(userpassAgainValue)){
						   return;
						}else{
							if(userpassAgainValue==userpassValue){
								mui.ajax('',{
									data:{
										password:userpassAgainValue,
									},
									dataType:'json',
									type:'post',
									headers:{'Content-Type':'application/json'},
									success:function(data){
										data=JSON.stringify(data);
									    console.log(data);
									    alert(data);
									    if(data.code==200){
									    	mui.toast('重置密码成功');
									    	webtool.openPreView('login',function(wb){
									    		wb.show('slide-in-right',300);
									    	})
									    }else{
									    	mui.toast(data.message);
									    }
									},
									error:function(xhr,type,errorThrown){
										//异常处理；
										console.log(xhr)
									}
								})
							}else{
								mui.toast('两次密码输入不一致');
								return;
							}
						}
					}
				}
			}
			
			
			
		})
	})
</script>
</html>